﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class View_updateUser : System.Web.UI.Page
{
    AccessDAO dao = new AccessDAO();
    protected void Page_Load(object sender, EventArgs e)
    {
        IsAdmin.Admin();
        this.btnUpdate.Attributes.Add("onclick", "javascript:showmessagebox();");
        if (!Page.IsPostBack)
        {
            this.txtName.Text = Session["userName"].ToString();
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Session["userId"].ToString());
        //string name = Session["userName"].ToString();
        string name = this.txtName.Text;
        string pass = this.txtPass1.Text;
        if (pass.Equals(""))
        {
            pass = Session["pass"].ToString();
        }
        else
        {
            pass = this.txtPass1.Text;
        }
        string sql = "update userInfo set name='"+name+"',pass='" + pass + "' where id="+id;
        if (dao.getComm(sql)!=0)
        {
            Server.Transfer("welcome.aspx");
        }
        else
        {
            RegisterStartupScript("check", "<script language='javascript'>alert('对不起，修改失败！');</script>");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Server.Transfer("welcome.aspx");
    }
}
